/**
 * Created by wlc on 2018/5/13.
 */
/**
 * 模型面板-收缩与展开
 */
$(document).on("dblclick",'.model-panel', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var panel = $(tar).parents('.model-panel')[0];
    if (panel.className.indexOf("mini-panel")!==-1){
        panel.className = panel.className.replace("mini-panel","normal-panel");
    }else {
        panel.className = panel.className.replace("normal-panel","mini-panel");
    }
});

/**
 * 扇形工具栏-收缩与展开
 */
$(document).on("dblclick",'.neurons', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var sectorLis;
    var neuronsModel = $(tar).parents('.neurons')[0];
    var isSector = false;
    var i;
    for (i=0;i<neuronsModel.children.length;i++){
        if (neuronsModel.children[i].className==="sector-tools"){
            isSector = true;
            break;
        }
    }
    if (!isSector){
        var sectorTools = $(SECTORTOOLS)[0];
        sectorTools.id = neuronsModel.id + "sectorTools";
        neuronsModel.appendChild(sectorTools);
        setTimeout("openSectorTools("+neuronsModel.id+")",100);
    } else {
        sectorLis = $('#'+neuronsModel.id + "sectorTools")[0].children[0].children;
        for (i=1;i<sectorLis.length;i++){
            sectorLis[i].style.transform = "rotate(-90deg)";
        }
        setTimeout("$('#"+neuronsModel.id+"')[0]"+".removeChild($('#"+neuronsModel.id + "sectorTools"+"')[0]);",500);
    }
});

/**
 * 通用
 * @param e
 */
document.ondblclick = function (e) {
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素
};

/**
 * 展开扇形工具栏
 * @param neuronsModelId
 */
function openSectorTools(neuronsModelId) {
    var sectorLis = $('#'+neuronsModelId+"sectorTools")[0].children[0].children;
    var ang = 30;
    for (var i=1;i<sectorLis.length;i++){
        sectorLis[i].style.transform = "rotate("+(-90+ang)+"deg)";
        ang += 30;
    }
}